package daily;

import java.util.*;

/**
 * @author MtRider
 * @version 1.0
 * @description 有效的字母异位词
 * @GiteeAndGithub MtRider
 * @date 2022/4/24 11:44
 */
public class demo14 {

    public static void main(String[] args) {
        System.out.println(isAnagram("asdf","asdf"));
    }

    //排序就可以了
    public static boolean isAnagram(String s, String t) {
        if(s.length()!=t.length()) {
            return false;
        }
        char[] sChar = s.toCharArray();
        char[] tChar = t.toCharArray();
        //对两个字符串中的字符进行排序
        Arrays.sort(sChar);
        Arrays.sort(tChar);
        return Arrays.equals(sChar, tChar);
    }
}
